package com.fubowen.lepton.ui.home.suggest

import androidx.recyclerview.widget.SortedListAdapterCallback
import com.fubowen.lepton.bean.Suggest

class SuggestSortedListAdapterCallback(_adapter: SuggestAdapter) :
    SortedListAdapterCallback<Suggest>(_adapter) {

    override fun compare(prev: Suggest?, next: Suggest?): Int {
        if (prev == null || next == null) {
            return 0
        }
        return (next.timestamp - prev.timestamp).toInt()
    }

    override fun areContentsTheSame(oldItem: Suggest?, newItem: Suggest?): Boolean {
        return oldItem == newItem
    }

    override fun areItemsTheSame(oldItem: Suggest?, newItem: Suggest?): Boolean {
        return oldItem?.title == newItem?.title
    }

}